#pragma once

class Kmeans
{
public:
	Kmeans(int inputD, double** input, int NumofCluster, int inputS);

private:
	int			numCluster;
	double**	inputData;
	int			inputDim;
	int			inputSize;

	int*		newSolution;
	int*		currentSolution;
	int			numIteration;

	double		currentCost;
	double		newCost;

	double**	currentCentroid;
	double**	newCentroid;

	double**	currentSum;
	double**	newSum;

	int*		currentElement;
	int*		newElement;

	double		coolingRate;
	double		currentT;
	double		minimumT;

	int			changedInput;
	int			newCluster;
	int			oldCluster;

	int*		finalSolution;
	double		finalCost;
	double**	finalCentroid;

private:
	void		norInput(void);

	void		findSolution(void);
	void		initialSolution(void);
	void		updateSolution(void);

	double		getInitialCost(void);
	double		getNewCost(void);

	double		wDistance(double* x, double* y);

	int			findCluster(double* currentinput);

	void		takeChange(void);
	void		rejectChange(void);

	void		sAnnealing(void);

public:
	int*		getResluts(void);
	double**	getCentroid(void);
	double		getCost(void);
	int			getIteration(void);
	int			getTest(double* tesData);
	CString		douTostr(double dou);

public:
	virtual ~Kmeans(void);
};
